package pl.edu.agh.neuraleconomy.core.experiment.statistics;

import java.io.File;
import java.util.Date;
import java.util.List;

import pl.edu.agh.neuraleconomy.common.utils.DateUtils;
import pl.edu.agh.neuraleconomy.core.simulation.SimulationEngine;
import pl.edu.agh.neuraleconomy.core.simulation.Transaction;
import pl.edu.agh.neuraleconomy.core.ta.advice.Advice;

public class TransactionStatistic extends SaveToFileStatistic{

	public TransactionStatistic(File dir, String fileName) {
		super(dir, fileName);
	}

	@Override
	protected String iterationString(Date date, SimulationEngine simulation, List<Advice> advices, List<Transaction> transactionsMade) {
		StringBuffer buff = new StringBuffer();
		if(!transactionsMade.isEmpty()){
			buff.append(DateUtils.formatDate(date));
			buff.append("\n");
			
			for(Transaction t : transactionsMade){
				buff.append(String.format("%s %s %s", String.valueOf(t.getType()), String.valueOf(t.getCompany()), String.valueOf(t.getAmount())));
				buff.append("\n");
			}
		}
		return buff.toString();
	}

}
